From 3046558a7f24fc58c7116424c00fb30417d5e458 Mon Sep 17 00:00:00 2001 From: parkrrrr Date: Wed, 15 Oct 2003 16:31:32 +0000 Subject: [PATCH] Same change as the previous one for Cetus. These crashes haven't been reported, but they could have happened under the same circumstances. Well, except for the ifdefed-out code in mapopolis, which is included for completeness. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@520 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/magnav.c | 5 +++-- gpsbabel/magproto.c | 14 ++++++++++---- gpsbabel/mapopolis.c | 5 +++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gpsbabel/magnav.c b/gpsbabel/magnav.c index 269c1313d..f7c13815e 100644 --- a/gpsbabel/magnav.c +++ b/gpsbabel/magnav.c @@ -155,11 +155,12 @@ my_writewpt(const waypoint *wpt) wpt->shortname; rec = xcalloc(sizeof(*rec)+56,1); - + + tm = NULL; if ( wpt->creation_time ) { tm = gmtime( &wpt->creation_time); } - else { + if ( !tm ) { time( &tm_t ); tm = gmtime( &tm_t ); } diff --git a/gpsbabel/magproto.c b/gpsbabel/magproto.c index 4f19669e9..3ed780db5 100644 --- a/gpsbabel/magproto.c +++ b/gpsbabel/magproto.c @@ -1203,12 +1203,18 @@ void mag_track_disp(const waypoint *waypointp) ilat = waypointp->position.latitude.degrees; ilon = waypointp->position.longitude.degrees; + tm = NULL; if (waypointp->creation_time) { tm = gmtime(&waypointp->creation_time); - hms = tm->tm_hour * 10000 + tm->tm_min * 100 + tm->tm_sec; - date = tm->tm_mday * 10000 + tm->tm_mon * 100 + tm->tm_year; - fracsec = waypointp->centiseconds; - } else { + if ( tm ) { + hms = tm->tm_hour * 10000 + tm->tm_min * 100 + + tm->tm_sec; + date = tm->tm_mday * 10000 + tm->tm_mon * 100 + + tm->tm_year; + fracsec = waypointp->centiseconds; + } + } + if (!tm) { date = 0; fracsec = 0; } diff --git a/gpsbabel/mapopolis.c b/gpsbabel/mapopolis.c index a6bf20e0f..2cf8f9a99 100644 --- a/gpsbabel/mapopolis.c +++ b/gpsbabel/mapopolis.c @@ -200,11 +200,12 @@ my_writewpt(const waypoint *wpt) wpt->shortname; rec = xcalloc(sizeof(*rec)+56,1); - + + tm = NULL; if ( wpt->creation_time ) { tm = gmtime( &wpt->creation_time); } - else { + if ( !tm ) { time( &tm_t ); tm = gmtime( &tm_t ); } -- 2.30.2